//
//  UILabel+Extension.swift
//  weibo
//
//  Created by 罗李苏 on 16/5/23.
//  Copyright © 2016年 Apple. All rights reserved.
//

import UIKit
//设置对齐的边距
let StatusCellMargin: CGFloat = 8
extension UILabel{
    
    //给UILabel添加便利的构造函数
    convenience init(title: String, font: CGFloat, textColor: UIColor, alignment: NSTextAlignment = .Center){
        
        //调用指定的构造函数 实例化对象
        self.init()
        self.text = title
        self.font = UIFont.systemFontOfSize(font)
        self.textColor = textColor
        textAlignment = alignment
        //自动换行
        numberOfLines = 0
        if alignment == .Left {
            //设置最大布局宽度
            preferredMaxLayoutWidth = ScreenWidth - 2 * StatusCellMargin
        }
        //自适应大小
        sizeToFit()
    
    }
}
